Ensure waypoints are named uniquely before writing.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sat, 14 Jan 2006 03:48:29 +0000 (03:48 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sat, 14 Jan 2006 03:48:29 +0000 (03:48 +0000)
gpsbabel/mapsend.c

index f3515f9831b47b1fcad16b7d6f21746367663b2a..ebea4cb18500acc91f59a6bc6b3c22cab1183dd1 100644 (file)
@@ -1,7 +1,7 @@
 /*
     Access Magellan Mapsend files.
 
-    Copyright (C) 2002 Robert Lipe, robertlipe@usa.net
+    Copyright (C) 2002-2006 Robert Lipe, robertlipe@usa.net
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -28,6 +28,7 @@
 static FILE *mapsend_file_in;
 static FILE *mapsend_file_out;
 static short_handle mkshort_handle;
+static short_handle wpt_handle;
 
 static int route_wp_count;
 static int mapsend_infile_version;
@@ -94,6 +95,11 @@ mapsend_wr_init(const char *fname)
 {
        mapsend_file_out = xfopen(fname, "wb", MYNAME);
        mkshort_handle = mkshort_new_handle();
+
+       wpt_handle = mkshort_new_handle();
+       setshort_whitespace_ok(wpt_handle, 1);
+       setshort_length(wpt_handle, 8);
+
        route_wp_count = 0;
 }
 
@@ -102,6 +108,7 @@ mapsend_wr_deinit(void)
 {
        fclose(mapsend_file_out);
        mkshort_del_handle(&mkshort_handle);
+       mkshort_del_handle(&wpt_handle);
 }
 
 static void
@@ -335,7 +342,8 @@ mapsend_waypt_pr(const waypoint *waypointp)
         * them into the Mapsend file.
         */
 
-       tmp = xstrdup(sn);
+       
+       tmp = mkshort(wpt_handle, sn);
        c = tmp ? strlen(tmp) : 0;
        fwrite(&c, 1, 1, mapsend_file_out);
        fwrite(tmp, c, 1, mapsend_file_out);